<?php include '/../header.php';?>
    
<link rel="stylesheet" type="text/css" href="<?php echo css_url().'body_general.css'?>">
<section id='body'>
    <div class="left-section">
        
    </div>
    <link rel="stylesheet" type="text/css" href="<?php echo css_url().'general_form.css'?>">
    <div class="main-section">
        <div class="title tab">
            <b>Post Management: </b>
            <div id="add-post" class="margin-left add-btn" style='position:relative; left: 11%'>+</div>
        </div>
        <div class="content-section">
            <?php 
                if(count($UserPosts) ==0){
                    echo "<div class='annoucement tab' >You have no post. You can create a new one by clicking + button</div>";
                }else{
                    $CI =& get_instance();
                    $CI->load->library('table');
                    $data = array();
                    $data[] = array('','Subject','Field', 'Date');

                    $checkbox_number = 0;

                    foreach($UserPosts as $Post){
                        $data[] = array("<input id='checkbox".$checkbox_number."' name='checkbox' type='checkbox'>"
                                ,$Post['Subject']
                                ,$Post['CategoryName']
                                ,$Post['PostDate']);
                    }
                    $tmpl = array(
                            'cell_start'          => '<td style="width: auto">',
                            'cell_end'            => '</td>',
                    );
                    $CI->table->set_template($tmpl);
                    echo $CI->table->generate($data);
                }
            ?>
        </div>
    </div>
</section>

<script>
    $("#add-post").on("click",function(){
        $.get("<?php echo site_url().'/pages/us2_post_create' ?>", function(data){
                $(".main-section").empty();
                $(".main-section").html(data);
        });
    });
</script>

<?php include '/../../footer.php';?>